﻿using IDogRepository;
using IDogService;
using Microsoft.Extensions.Logging;

namespace DogService
{
    public class BaseService<T> : IBaseService<T> where T : class, new()
    {
        protected readonly IBaseRepository<T> baseRepository;
        protected readonly ILogger<BaseService<T>> Nlog;

        public BaseService(IBaseRepository<T> repository, ILogger<BaseService<T>> logger)
        {
            baseRepository = repository;
            Nlog = logger;
        }

        public bool Creat(T t)
        {
            //Nlog.LogInformation("执行了BaseService里的Create方法");
            return baseRepository.Creat(t);
        }

        public List<T> GetAll()
        {
            //Nlog.LogInformation("执行了BaseService里的GetAll方法(获取所有的数据)");
            return baseRepository.GetAll().ToList();
        }
    }
}